home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0023_Get the active code page.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-18  |  2KB  |  76 lines

  1. { Gets the active (set by user) and system (at boot byte) code page.
  2.   Part of the Heartware Toolkit v2.00 (HTelse.PAS) for Turbo Pascal.
  3.   Author: Jose Almeida. P.O.Box 4185. 1504 Lisboa Codex. Portugal.
  4.           I can also be reached at RIME network, site ->TIB or #5314.
  5.   Feel completely free to use this source code in any way you want, and, if
  6.   you do, please don't forget to mention my name, and, give me and Swag the
  7.   proper credits. }
  8.  
  9. PROCEDURE Get_Code_Page(var Active_CP : word;
  10.                        var System_CP : word;
  11.                        var Error_Code : byte);
  12. { DESCRIPTION:
  13.     Gets the active (set by user) and system (at boot byte) code page.
  14.   SAMPLE CALL:
  15.     Get_Code_Page(Active_CP,Default_CP,Error_Code);
  16.   RETURNS:
  17.     Active : active code page set by user
  18.     System : system code page at boot time
  19.     Error_Code
  20.       0 : no error
  21.       else : see The Programmers PC Source Book 3.191
  22.   NOTES:
  23.     Applies to all versions beginning with v3.3.
  24.     See Get_Code_Page_Text() in order to get string text. }
  25.  
  26. var
  27.   HTregs : registers;
  28.  
  29. BEGIN { Get_Code_Page }
  30.   HTregs.AX := $6601;
  31.   MsDos(HTregs);
  32.   if HTregs.Flags and FCarry <> 0 then
  33.     begin
  34.       Active_CP := $FFFF;           { on error set to $FFFF }
  35.       System_CP := $FFFF;           { on error set to $FFFF }
  36.       Error_Code := HTregs.AL;
  37.     end
  38.   else
  39.     begin
  40.       Active_CP := HTregs.BX;
  41.       System_CP := HTregs.DX;
  42.       Error_Code := 0;
  43.     end;
  44. END; { Get_Code_Page }
  45.  
  46.  
  47.  
  48. FUNCTION Get_Code_Page_Text(CP : word) : String14;
  49.  
  50. { DESCRIPTION:
  51.     Gets the current active code page in string form.
  52.   SAMPLE CALL:
  53.     St := Get_Code_Page_Text(860);
  54.   RETURNS:
  55.     e.g.: 'Portugal'
  56.   NOTES:
  57.     None. }
  58.  
  59. BEGIN { Get_Code_Page_Text }
  60.   case CP of
  61.     437 : Get_Code_Page_Text := 'USA English';
  62.     850 : Get_Code_Page_Text := 'Multilingual';
  63.     852 : Get_Code_Page_Text := 'CZ/SL/HU/PL/YU';
  64.           { CZ and SL = Czechoslovakia (Czech & Slovak) }
  65.           { HU        = Hungary                         }
  66.           { PL        = Poland                          }
  67.           { YU        = Yugoslavia                      }
  68.     854 : Get_Code_Page_Text := 'Spain';
  69.     860 : Get_Code_Page_Text := 'Portugal';
  70.     863 : Get_Code_Page_Text := 'Canada-French';
  71.     865 : Get_Code_Page_Text := 'Norway/Denmark';
  72.   else
  73.     Get_Code_Page_Text := 'Unknown';
  74.   end;
  75. END; { Get_Code_Page_Text }
  76.